package com.museum.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.museum.entity.DO.Area;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

/**
 * <p>
 * 部门表 Mapper 接口
 * </p>
 *
 * @author Ruiwen
 * @since 2020-12-19
 */
@Repository

public interface AreaMapper extends BaseMapper<Area> {
    @Select("select area_id from area where area_number =#{number}")
    int selectIdByNumber(Integer number);
    @Select("select count(1) from area where parent_id = #{areaId} and is_deteled = 0")
    int selectCountById(int areaId);
    @Select("select count(*) from area where area_number = #{areaNumber}")
    int selectCountByNumber(Integer areaNumber);
    @Select("select area_name from area where area_number = #{number}")
    String selectNameByNumber(Integer number);

    @Select("select  area_number from area where area_id =(SELECT parent_id FROM area WHERE area_number=#{areaNumber})")
    Integer findFatherNode(Integer areaNumber);

}
